package com.spirng.leetcode.day05;

import java.util.Stack;

public class MyQueue {
    Stack<Integer> stackIn;
    Stack<Integer> stackOut;
    public MyQueue() {
         stackIn=new Stack();
         stackOut=new Stack();
    }

    public void push(int x) {
          stackIn.push(x);
    }

    public int pop() {
       if(stackOut.isEmpty()){
           while (!stackIn.isEmpty()){
               stackOut.push(stackIn.pop());
           }
       }
       return  stackOut.pop();
    }

    public int peek() {
         int result= pop();
         this.push(result);
         return result;
    }

    public boolean empty() {
         return stackOut.empty()&& stackIn.empty();
    }
}
